--cl_plrinfohud.lua
--Draws the player info HUD, displaying Role and Money

local healthBarVal = 100	--For smoothing

local function drawPlrInfoHUD()	--For drawing the money hud
	draw.RoundedBox(10, 16, ScrH() - 144, 256 * 1.5, 128, Color(0, 0, 0, 100))	--Background with blue-ish tint
	
	draw.SimpleText(LocalPlayer():Nick(), "Trebuchet24", 24, ScrH() - 136, Color(255, 255, 255, 192), TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP)						--Player's Name
	draw.SimpleText(getJobInfo(LocalPlayer():GetJob()).name, "Trebuchet24", 24, ScrH() - 116, Color(255, 255, 255, 192), TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP)	--Player's Job
	draw.SimpleText("Payment: " .. MONEY_PREFIX .. getJobInfo(LocalPlayer():GetJob()).wage, "Trebuchet24", 246 * 1.5, ScrH() - 116, Color(255, 255, 255, 192), TEXT_ALIGN_RIGHT, TEXT_ALIGN_TOP)	--Player's Wage
	draw.SimpleText("Wallet: " .. tostring(LocalPlayer():GetNetworkedInt("wallet")), "Trebuchet24", 24, ScrH() - 96, Color(255, 255, 255, 192), TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP)
	
	local deltaH = LocalPlayer():Health() - healthBarVal
	deltaH = math.Clamp(deltaH, -1, 4)
	healthBarVal = healthBarVal + deltaH
	local health = healthBarVal
	if health < 0 then
		health = 0
	end
	local healthPercent = health / 100
	local healthPercentClamped = math.Clamp(healthPercent, 0, 1)
	
	draw.RoundedBox(10, 24, ScrH() - 44, 240 * 1.5, 20, Color(0, 0, 0, 255))		--Health bar border
	if health >= 10 then														--Don't draw if health is 0 (or below...) because it looks stupid
		draw.RoundedBox(10, 28 * 1.5, ScrH() - 42, healthPercentClamped * 236 * 1.5, 16, Color(128 + 64, 0, 0, 255))		--Health bar
	end
	draw.SimpleText(tostring(health) .. "%", "DefaultBold", 144 * 1.5, ScrH() - 34, Color(255, 255, 255, 255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
end
hook.Add("HUDPaint", "plrInfoHudDraw", drawPlrInfoHUD)

local function hidePlayerInfoHUDs(uiComponentName)
	if uiComponentName == "CHudHealth" then
		return false
	end
end
hook.Add("HUDShouldDraw", "hidePlayerInfoHuds", hidePlayerInfoHUDs)
